import java.util.HashSet;

public class demo1 {
    boolean [][]cow;
    boolean [][]low;
    boolean [][][]circle;
    public boolean isValidSudoku(char[][] board) {
        cow=new boolean[9][10];
        low=new boolean[9][10];
        circle=new boolean[3][3][10];
        return dfs(board);
    }
    public boolean dfs(char[][] board){
        for(int i=0;i<9;i++){
            for(int j=0;j<9;j++){
                if(board[i][j]!='.'){
                    int n=board[i][j]-'0';
                    if(!cow[i][n]&&!low[j][n]&&!circle[i/3][j/3][n]){
                        cow[i][n]=true;
                        low[j][n]=true;
                        circle[i/3][j/3][n]=true;                    }
                    else{
                        return false;
                    }
                }
            }
        }
        return true;
    }
}
